﻿using BHan.Model.Entity.Pojo;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BHan.Model.Config
{
    /// <summary>
    /// 菜单实体配置
    /// </summary>
    public class MenuModelConfig : IEntityTypeConfiguration<MenuModel>
    {
        /// <summary>
        /// FluentAPI 编写表的配置
        /// </summary>
        /// <param name="builder"></param>
        public void Configure(EntityTypeBuilder<MenuModel> builder)
        {
            builder.ToTable("sys_menu").HasComment("系统的菜单管理表");
            builder.HasKey(b => b.menuId);
            builder.HasIndex(b => b.menuName);
            builder.Property(b => b.menuId).HasComment("菜单id");
            builder.Property(b => b.menuName).HasComment("菜单名称").HasMaxLength(20);
            builder.Property(b => b.pMenuId).HasComment("父级菜单");
            builder.Property(b => b.orderNum).HasComment("菜单排序顺序");
            builder.Property(b => b.path).HasComment("地址（窗体Name）").HasMaxLength(50);
            builder.Property(b => b.icon).HasComment("图标").HasMaxLength(100);
            builder.Property(b => b.menuType).HasComment("菜单类型 C=目录 M=菜单 B=按钮").HasMaxLength(5).IsRequired();
            builder.Property(b => b.status).HasComment("状态( 正常, 禁用)");
            builder.Property(b => b.delFlag).HasComment("逻辑删除").HasDefaultValue(false);
            builder.Property(b => b.remark).HasComment("备注").HasMaxLength(255);
            builder.Ignore(b => b.subItems);
        }
    }
}
